package com.guoxue.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.guoxue.domain.InventoryVo;
import com.guoxue.service.IInventoryService;

@Component
public class CleanInventoryTaskTime {
	
	@Resource
	private IInventoryService inventoryService;
	
	private static final long PERIOD_DAY = 24 * 60 * 60 * 1000;  
	
	TimerTask task = new TimerTask() {
		@Override
		public void run() {
			System.out.println("清理背包");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			String d = df.format(new Date());
			List<InventoryVo> InventoryList = inventoryService.getCurrentTimeData(d);
			if(null != InventoryList){
				for(InventoryVo i : InventoryList){
					i.setSysflag(1);
					inventoryService.saveInventory(i);
				}
			}
		}
	};
	public void run(){
		Timer timer = new Timer();  
		timer.schedule(task,PERIOD_DAY);  
	}
	
}
